import regeneratorRuntime from '../../../../utils/runtime.js';
import img_list from '../../../../utils/util.js';
import { setTabBar, setTabList } from '../../../../utils/util'
import { getData, setData, clearData, dataKey } from '../../../../utils/storage.js';
import shareFun from '../../../../utils/shareFun.js';
import {
  pindao,
  queryHost,
  getLiveList,
  getLiveClassify,
} from '../../../../utils/imapi.js';
var app = getApp()
Page({

  
  /**
   * 页面的初始数据
   */
  data: {
    tabIndex:1,
    zIndex: true,
    title: '星品短视频',
    bgColor: 'white',
    liveList: [],
    img_list: {},
    canLoadMore: true,
    size: 80,
    wsize: 750,
    color: "#6D55ED",
    bottom:app.globalData.isIphonex==1?'100rpx':'10rpx',
    page:1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    this.setData({
      img_list: img_list.img_list
    })

    shareFun.hidenShareMenu();
  

    this.loadData()

  },
  
  imgload(e) {
    var index = e.detail.index;
    this.data.liveList[index].imgShow = true;
  },
 
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
   
  },


  loadData:async function(){

 
    let liveData = await pindao({ elite_id: 130, page_index: this.data.page, page_size: 10 })

    let arr =[]
    if(!liveData.data){
        arr=[]
    }else{
        arr=liveData.data
    }

   
    this.setData({
        liveList:  this.data.liveList.concat(arr)
    })

    //console.log(this.data.liveList);

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: async function () {
    wx.showNavigationBarLoading() //在标题栏中显示加载
   
    this.setData({
        page:1
    })

    this.loadData()

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: async function () {
   
    
    
    this.setData({
        page:this.data.page+1
    })

    this.loadData()

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})